﻿using System;
using System.Collections.Generic; 
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class shuangse : System.Web.UI.Page
{
    protected List<Model.LotteryAnnouncement> arlist = null;
    protected string[] SSQList = null;
    protected string SSQblue = null;
    protected DataTable dtPaperList = new DataTable();
    protected int jinqiCount = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            jinqiCount = 30;
            bindData(30);
        } 
    }

    protected void bindData(int maxValue)
    {

        int Count = 0;
        arlist = BLL.LotteryAnnouncement.GetPageList_Where(0, maxValue, 3, out  Count);

        if (arlist != null)
        {
            dtPaperList.Columns.Add("Id", typeof(int));
            dtPaperList.Columns.Add("Heshi", typeof(string));
            dtPaperList.Columns.Add("Zusan", typeof(string));
            dtPaperList.Columns.Add("Zuliu", typeof(string));
            dtPaperList.Columns.Add("Baozi", typeof(string)); 

            for (int i = 0; i < arlist.Count; i++)
            {
                DataRow newRow = dtPaperList.NewRow();
                newRow["Id"] = i + 1;
                //重号
                string[] redBall = arlist[i].LotteryNo.Split(',');
                string Zusan = "";
                string Zuliu = "";
                string Baozi = ""; 
                int hezhi = 0;//和值 
                for (int m = 0; m < redBall.Length; m++)
                { 
                    bindTiaoxing(m,int.Parse(redBall[m]));
                    hezhi += int.Parse(redBall[m]); 
                }
                if (redBall.Length >= 3)
                {
                    if ((redBall[0] == redBall[1] && redBall[0] != redBall[2]) || (redBall[0] != redBall[1] && redBall[1] == redBall[2]) || (redBall[0] == redBall[2] && redBall[0] != redBall[1]))
                    {
                        Zusan = "组三";
                    }
                    if (redBall[0] != redBall[1] && redBall[0] != redBall[2] && redBall[1] != redBall[2] && (int.Parse(redBall[0]) + 2) != int.Parse(redBall[2]))
                    {
                        Zuliu = "组六";
                    } 
                    if (redBall[0] == redBall[1] && redBall[0] == redBall[2] && redBall[1]== redBall[2])
                    {
                        Zuliu = "豹子";
                    }
                }
                newRow["Heshi"] = hezhi;
                newRow["Zusan"] = Zusan;
                newRow["Zuliu"] = Zuliu;
                newRow["Baozi"] = Baozi; 
                dtPaperList.Rows.Add(newRow);

            }


        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        jinqiCount = int.Parse(DropDownList1.SelectedValue);
        bindData(int.Parse(DropDownList1.SelectedValue));
    }
    protected int[] TiaoxingDT = new int[27];
    /// <summary>
    /// 计算条形码数值
    /// </summary>
    /// <param name="type">0百位，1十位，2个位</param>
    /// <param name="data">数字</param>
    protected void bindTiaoxing(int type,int data)
    {
        for (int i = 0; i < 27; i++)
        {
            if ((data + 9 * type) == (i + 1))
            {
                TiaoxingDT[data +9*type-1] +=1 ;
            }
        }
    }
}